package com.ken.elmssm.mapper;

import com.ken.elmssm.bean.Business;
import com.ken.elmssm.common.Pager;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BusinessMapper extends BaseMapper<Business> {

    /**
     * 新增
     * @param object
     * @return
     */
    boolean add(Business object);

    /**
     * 删除
     * @param id
     * @return
     */
    @Delete("delete from business where businessId=#{businessId}")
    boolean deleteById(Integer id);

    /**
     * 修改
     * @param object
     * @return
     */
    @Update("update business set password=#{password}," +
            "salt=#{salt},businessName=#{businessName},businessAddress=#{businessAddress}" +
            ",businessExplain=#{businessExplain},starPrice=#{starPrice},deliveryPrice=#{deliveryPrice} where businessId=#{businessId}")
    boolean edit(Business object);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select bussinessId,password,businessName,businessAddress,businessExplain,starPrice,deliveryPrice from business where businessId=#{businessId}")
    Business findById(Integer id);

    /**
     * 查询数据条数
     * @param pager
     * @return
     */
    int findTotal(Pager<Business> pager);

    /**
     * 根据对象类型进行查找
     * @param pager
     * @return
     */
    List<Business> findByPager(Pager<Business> pager);

    /**
     * 根据id列表进行删除
     * @param ids
     * @return
     */
    boolean deleteByIds(List<Integer> ids);
}
